home *** CD-ROM | disk | FTP | other *** search
/ Tech Arsenal 1 / Tech Arsenal (Arsenal Computer).ISO / tek-11 / drivel.zip / CURRPATH.ASM < prev    next >
Assembly Source File  |  1993-01-04  |  2KB  |  54 lines

  1.     TITLE   "Get Current Path"
  2.     PAGE    60,132
  3.  
  4. .MODEL LARGE
  5. .CODE
  6.  
  7. ;
  8. ;   compile:    masm /mx currpath;
  9. ;
  10.  
  11. ;
  12. ;   Function:       CurrPath()
  13. ;   Parameters:     char * - place to store the current path
  14. ;   Returns:        ax = error code or 0 if successful
  15. ;   Author:         Mike Taylor
  16. ;   Date:           16 December 1988
  17. ;
  18. ;   Description:    This function call DOS int 21h function 47h to find out the
  19. ;                     current path.
  20. ;
  21. ;   Called By:      Microsoft C large memory model routine
  22.  
  23.             PUBLIC  _CurrPath
  24. _CurrPath   PROC
  25.  
  26.     push    bp              ; save the caller's base pointer register
  27.     mov     bp,sp           ; establish our stack frame by saving the current
  28.                             ;   stack pointer
  29.     push    si              ; save caller's registers that we will use
  30.     push    ds
  31.  
  32.     mov     si,[bp + 6]     ; set up buffer's offset
  33.     mov     ax,[bp + 8]     ; set up buffer's segment
  34.     push    ax
  35.     pop     ds
  36.     xor     ax,ax           ; clear the ax register
  37.     mov     dl,0            ; dl = drive to get path for:  0 = current drive
  38.     mov     ah,47h          ; set up the call to DOS's Get Current Path function
  39.     int     21h             ;   ah = function 47h of interrupt 21h
  40.  
  41.     jc      _cp1            ; if error returned, exit routine with ax = error
  42.     xor     ax,ax           ;   else clear ax to show no error
  43.  
  44. _cp1:
  45.     pop     ds              ; restore caller's registers
  46.     pop     si
  47.     pop     bp              ; restore caller's base pointer
  48.  
  49.     ret
  50.  
  51. _CurrPath   ENDP
  52.  
  53.     END
  54.